<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>测评小组端-学业表现测评</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description"/>
    <meta content="Coderthemes" name="author"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <!--    &lt;!&ndash; App favicon &ndash;&gt;-->
    <!--    <link rel="shortcut icon" href="./assets/images/favicon.ico">-->

    <!--    &lt;!&ndash; App css &ndash;&gt;-->
    <!--    <link href="./css/bootstrap.min.css" rel="stylesheet" type="text/css"/>-->
    <!--    <link href="./css/icons.min.css" rel="stylesheet" type="text/css"/>-->
    <!--    <link href="./css/app.css" rel="stylesheet" type="text/css"/>-->

    <!--    &lt;!&ndash; App favicon &ndash;&gt;-->
    <!--    <link rel="shortcut icon" href="assets/images/favicon.ico">-->

    <!--    &lt;!&ndash; Sweet Alert&ndash;&gt;-->
    <!--    <link href="css/vendor/sweetalert2.min.css" rel="stylesheet" type="text/css"/>-->
    <!--    &lt;!&ndash; third party css &ndash;&gt;-->
    <!--    <link href="css/vendor/dataTables.bootstrap4.css" rel="stylesheet" type="text/css">-->
    <!--    &lt;!&ndash; App css &ndash;&gt;-->
    <!--    <link href="css/app.css" rel="stylesheet" type="text/css"/>-->

    <!-- App favicon -->
    <link rel="shortcut icon" href="/stuInfoSystem/assets/images/favicon.ico">

    <!-- App css -->
    <link href="/stuInfoSystem/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/stuInfoSystem/css/icons.min.css" rel="stylesheet" type="text/css"/>
    <link href="/stuInfoSystem/css/app.css" rel="stylesheet" type="text/css"/>

    <!-- App favicon -->
    <link rel="shortcut icon" href="/stuInfoSystem/assets/images/favicon.ico">

    <!-- Sweet Alert-->
    <link href="/stuInfoSystem/css/vendor/sweetalert2.min.css" rel="stylesheet" type="text/css"/>
    <!-- third party css -->
    <link href="/stuInfoSystem/css/vendor/dataTables.bootstrap4.css" rel="stylesheet" type="text/css">
    <!-- App css -->
    <link href="/stuInfoSystem/css/app.css" rel="stylesheet" type="text/css"/>


</head>

<body>
<!-- Begin page -->
<div id="wrapper">


    <!-- ========== Left Sidebar Start ========== -->
    <div th:include="commons/surveySideBar :: sidebar"/>
    <!-- Left Sidebar End -->

    <!-- ============================================================== -->
    <!-- Start Page Content here -->
    <!-- ============================================================== -->

    <div class="content-page">
        <div class="content">

            <!-- TopBar Start -->
            <div th:replace="commons/surveyTopbar :: topbar "/>
            <!-- end TopBar -->

            <!-- Start Content-->
            <div class="container-fluid">
                <!-- start page title -->
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box">
                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item"><a href="#">首页</a></li>
                                    <li class="breadcrumb-item active">学业表现审核</li>
                                </ol>
                            </div>
                            <h4 class="page-title">学业表现审核:</h4>
                        </div>
                    </div>
                </div>
            </div>
            <!-- end page title -->


            <!--搜索区和功能区-->
            <form method="get" action="" th:action="@{/findAcademicPage/1/10}">
                <div class="form-group row" style="width: 510px;">
                    <label class="col-sm-2 col-form-label">查找：</label>
                    <div class="col-sm-10">
                        <div class="input-group">
                            <input type="text" id="condition" name="condition" th:value="${searchName}"
                                   class="form-control" placeholder="请输入您要查找学生的姓名" aria-label="">
                            <div class="input-group-append">
                                <button class="btn btn-dark" id="searchBtn" type="submit">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>


            <!--数据表-->
            <table class="table table-hover">
                <tr>
                    <th>序号</th>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>基本分</th>
                    <th>挂科数</th>
                    <th>预计得分</th>
                    <th>审核状态</th>
                    <th>操作栏</th>
                </tr>
                <tr th:each="stu,num : ${students}">
                    <td th:text="${num.count}">1</td>
                    <td class="stuId" th:text="${stu.sutId}">1840129269</td>
                    <td th:text="${stu.stuName}">zzp</td>
                    <td th:text="${stu.basicPoints}">80</td>
                    <td th:text="${stu.failedNum}">2</td>
                    <td th:text="${stu.subTotal}">6.0</td>
                    <td class="checkStatus" th:if="${stu.status == '0'}" style="color:red;">未提交</td>
                    <td class="checkStatus" th:if="${stu.status == '1'}" style="color:blue;">待审核</td>
                    <td class="checkStatus" th:if="${stu.status == '2'}" style="color:green;">已通过</td>
                    <td class="checkStatus" th:if="${stu.status == '3'}" style="color:black;">待修改</td>
                    <td>
                        <button type="button" th:if="${stu.status != '1'}" disabled class="btn btn-success btn-sm pass">
                            审核通过
                        </button>
                        <button type="button" th:if="${stu.status == '1'}" class="btn btn-success btn-sm pass">审核通过
                        </button>

                        <button type="button" th:if="${stu.status != '2'}" disabled class="btn btn-info btn-sm cancel">
                            撤销审核
                        </button>
                        <button type="button" th:if="${stu.status == '2'}" class="btn btn-info btn-sm cancel">撤销审核
                        </button>

                        <button type="button" th:if="${stu.status != '1'}" disabled
                                class="btn btn-danger btn-sm reBack">驳回修改
                        </button>
                        <button type="button" th:if="${stu.status == '1'}" class="btn btn-danger btn-sm reBack">驳回修改
                        </button>
                    </td>
                </tr>
            </table>
            <!--分页条-->

            <div id="basic-datatable_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">
                <div class="row">
                    <div class="col-sm-12 col-md-7">
                        <div class="dataTables_paginate paging_simple_numbers" id="basic-datatable_paginate">
                            <ul class="pagination pagination-rounded">
                                <li class="paginate_button page-item previous" id="basic-datatable_previous">
                                    <a href="#" th:href="@{'/findAcademicPage/'+${page - 1 < 1 ? 1 : page - 1}+'/10'}"
                                       aria-controls="basic-datatable" data-dt-idx="0" tabindex="0" class="page-link">
                                        <i class="mdi mdi-chevron-left"> </i>
                                    </a></li>


                                <li class="paginate_button page-item"
                                    th:class="${i==page?'paginate_button page-item active':'paginate_button page-item'}"
                                    th:each="i : ${#numbers.sequence(1,totalPageNum)}"><a href="#"
                                                                                          th:href="@{'/findAcademicPage/'+${i}+'/10'}"
                                                                                          aria-controls="basic-datatable"
                                                                                          data-dt-idx="1"
                                                                                          tabindex="0" class="page-link"
                                                                                          th:text="${i}"></a></li>


                                <li class="paginate_button page-item next" id="basic-datatable_next"><a href="#"
                                                                                                        th:href="@{'/findAcademicPage/'+${page + 1 > totalPageNum ? totalPageNum : page + 1}+'/10'}"
                                                                                                        aria-controls="basic-datatable"
                                                                                                        data-dt-idx="7"
                                                                                                        tabindex="0"
                                                                                                        class="page-link"><i
                                        class="mdi mdi-chevron-right"></i></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

        </div> <!-- content -->


        <!-- Footer Start -->
        <div th:replace="commons/footer :: foot"></div>
        <!-- end Footer -->
    </div>

    <!-- ============================================================== -->
    <!-- End Page content -->
    <!-- ============================================================== -->

</div>
<!-- END wrapper -->

<!--&lt;!&ndash; App js &ndash;&gt;-->
<!--<script src="./js/vendor.js"></script>-->
<!--<script src="./js/app.js"></script>-->

<!--&lt;!&ndash; Plugins js &ndash;&gt;-->
<!--<script src="./js/vendor/Chart.bundle.js"></script>-->
<!--<script src="./js/vendor/jquery.sparkline.min.js"></script>-->
<!--<script src="./js/vendor/jquery.knob.min.js"></script>-->
<!--<script src="./js/pages/dashboard.init.js"></script>-->

<!--&lt;!&ndash; 表单js&ndash;&gt;-->
<!--<script src="js/vendor/jquery.dataTables.js"></script>-->
<!--<script src="js/vendor/dataTables.bootstrap4.js"></script>-->
<!--<script src="js/vendor/dataTables.responsive.min.js"></script>-->
<!--<script src="js/vendor/responsive.bootstrap4.min.js"></script>-->
<!--<script src="js/vendor/dataTables.buttons.min.js"></script>-->

<!--<script src="js/vendor/buttons.print.min.js"></script>-->
<!--<script src="js/vendor/dataTables.keyTable.min.js"></script>-->
<!--<script src="js/vendor/dataTables.select.min.js"></script>-->

<!--<script src="js/pages/datatables.init.js"></script>-->

<!--&lt;!&ndash; 表单js&ndash;&gt;-->
<!--<script src="js/vendor/sweetalert2.min.js"></script>-->
<!--&lt;!&ndash; 按钮js&ndash;&gt;-->
<!--<script src="js/pages/sweet-alerts.init.js"></script>-->

<!-- App js -->
<script src="/stuInfoSystem/js/vendor.js"></script>
<script src="/stuInfoSystem/js/app.js"></script>

<!-- Plugins js -->
<script src="/stuInfoSystem/js/vendor/Chart.bundle.js"></script>
<script src="/stuInfoSystem/js/vendor/jquery.sparkline.min.js"></script>
<script src="/stuInfoSystem/js/vendor/jquery.knob.min.js"></script>
<script src="/stuInfoSystem/js/pages/dashboard.init.js"></script>

<!-- 表单js-->
<script src="/stuInfoSystem/js/vendor/jquery.dataTables.js"></script>
<script src="/stuInfoSystem/js/vendor/dataTables.bootstrap4.js"></script>
<script src="/stuInfoSystem/js/vendor/dataTables.responsive.min.js"></script>
<script src="/stuInfoSystem/js/vendor/responsive.bootstrap4.min.js"></script>


<script src="/stuInfoSystem/js/vendor/buttons.print.min.js"></script>
<script src="/stuInfoSystem/js/vendor/dataTables.keyTable.min.js"></script>
<script src="/stuInfoSystem/js/vendor/dataTables.select.min.js"></script>

<script src="/stuInfoSystem/js/pages/datatables.init.js"></script>

<!--引入layer-->
<script src="/stuInfoSystem/js/layer/layer.js"></script>
<!-- 表单js-->
<script src="/stuInfoSystem/js/vendor/sweetalert2.min.js"></script>
<!-- 按钮js-->
<script src="/stuInfoSystem/js/pages/sweet-alerts.init.js"></script>

<script>

    // 给所有的审核通过添加点击事件
    $('.pass').click(function () {
        // 获取当前点击的行对象
        var rowObj = $(this).parents('tr')
        var thisObj = $(this);

        layer.confirm('信息确认无误？', {
            btn: ['确认通过', '取消'] //按钮
        }, function () {
            // 通过
            // 获取当前条目的学生id
            var stuId = rowObj.children('.stuId').text();
            $.post('/stuInfoSystem/changeAcademicStatus', {"stuId": stuId, "status": "2", "msg": ""}, function (data) {
                if ("ok" === data) {
                    // 修改状态样式
                    rowObj.children('.checkStatus').removeAttr("style");
                    rowObj.children('.checkStatus').attr("style", "color:green;");
                    rowObj.children('.checkStatus').text("已通过");
                    thisObj.attr("disabled", "disabled");
                    // 唤醒撤销审核
                    thisObj.next().removeAttr("disabled");
                    thisObj.next().next().attr("disabled", "disabled");
                    layer.msg('审核通过', {icon: 1});
                } else {
                    layer.msg('服务器正忙！', {icon: 5});
                }
            }, 'text');
        }, function () {
            // 取消，无所事事
        });
    });

    // 给所有的撤销审核添加点击事件
    $('.cancel').click(function () {
        // 获取当前点击的行对象
        var rowObj = $(this).parents('tr')
        var thisObj = $(this);

        layer.confirm('您确认撤销审核吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            // 通过
            // 获取当前条目的学生id
            var stuId = rowObj.children('.stuId').text();
            $.post('/stuInfoSystem/changeAcademicStatus', {"stuId": stuId, "status": "1", "msg": ""}, function (data) {
                if ("ok" === data) {
                    // 修改状态样式
                    rowObj.children('.checkStatus').removeAttr("style");
                    rowObj.children('.checkStatus').attr("style", "color:blue;");
                    rowObj.children('.checkStatus').text("待审核");
                    thisObj.attr("disabled", "disabled");
                    // 唤醒审核通过和驳回修改
                    thisObj.prev().removeAttr("disabled");
                    thisObj.next().removeAttr("disabled");
                    layer.msg('撤销成功', {icon: 1});
                } else {
                    layer.msg('服务器正忙！', {icon: 5});
                }
            }, 'text');
        }, function () {
            // 取消，无所事事
        });
    });

    // 给所有驳回修改按钮添加点击事件
    $(".reBack").click(function () {
        // 获取当前点击的行对象
        var rowObj = $(this).parents('tr')
        var thisObj = $(this);

        layer.prompt({title: '请输入驳回原因', formType: 2}, function (text, index) {
            layer.close(index);
            // 确定后执行的代码
            // 获取当前条目的学生id
            var stuId = rowObj.children('.stuId').text();
            $.post('/stuInfoSystem/changeAcademicStatus', {
                "stuId": stuId,
                "status": "3",
                "msg": text
            }, function (data) {
                if ("ok" === data) {
                    // 修改状态样式
                    rowObj.children('.checkStatus').removeAttr("style");
                    rowObj.children('.checkStatus').attr("style", "color:black;");
                    rowObj.children('.checkStatus').text("待修改");
                    thisObj.attr("disabled", "disabled");
                    // 禁用审核通过按钮
                    thisObj.prev().prev().attr("disabled", "disabled");
                    layer.msg('驳回信息已发送！', {icon: 1});
                } else {
                    layer.msg('服务器正忙！', {icon: 5});
                }
            }, 'text');
        });
    });

</script>
</body>
</html>